﻿using System;

namespace RockBus.CacheManager.Interfaces
{
    public class ValueFactory
    {
        protected ValueFactory(Func<object> func, bool isThreadSafe, int? timeToLiveSecs = null)
        {
            this.Func = func;
            this.IsThreadSafe = isThreadSafe;
            this.TimeToLiveSecs = timeToLiveSecs;
        }

        public Func<object> Func { get; set; }

        public bool IsThreadSafe { get; set; }

        public int? TimeToLiveSecs { get; set; }

        public object LockObject = new object();
    }

    public class ValueFactory<T> : ValueFactory
        where T : class
    {
        public ValueFactory(Func<T> func, bool isThreadSafe, int? timeToLiveSecs = null)
            : base(new Func<object>(func), isThreadSafe, timeToLiveSecs)
        {
        }
    }
}